package com.student.Activitys.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.io.Serializable;
import java.util.List;

/**
 * 项目名称：
 * 类描述：主页面 activity + viewPager 滑动 Adapter
 * 创建人：张飞祥
 * 创建时间：2017/9/8 17:06
 * 修改人：张飞祥
 * 修改时间：2017/9/8 17:06
 * 修改备注：
 */
public class ActivityPagerAdapter extends PagerAdapter implements Serializable {
    private List<View> views;

    public ActivityPagerAdapter(List<View> views) {
        this.views = views;
    }

    @Override
    public int getCount() {
        return views.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position), 0);
        return views.get(position);
    }
}